<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>金山算法</title>
</head>
<body>
<script>
    var arr=[0,1,3,4,5,7,9,12,11];
    var target=12;
    function add(arr,target){
        var i=0;
        var j=arr.length-1;
        var flag=false;
       while(i<=j){
            if(arr[i]+arr[j]>target){
                j--;
               flag=false;
            }else if(arr[i]+arr[j]<target){
                i++;
                flag=false;
            }else{
                console.log(i + "     :" + arr[i] + "      ", j + ":" + arr[j]);
                return true;
            }
        }
    }
    add(arr,target);
</script>
</body>
</html>